package com.glory.brepda.adapter;

import androidx.annotation.Nullable;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.brepda.R;
import com.glory.brepda.entity.PmsEqpHisEntity;
import com.glory.brepda.entity.SheetInfoEntity;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


public class PmsEqpHisListAdapter extends BaseQuickAdapter<PmsEqpHisEntity, BaseViewHolder> {

    private OnClickListener mListener;

    public PmsEqpHisListAdapter(@Nullable List<PmsEqpHisEntity> data) {
        super(R.layout.adapter_check_pmshis, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, PmsEqpHisEntity item) {
        helper.setText(R.id.tvCheckID,item.getPeriodId());
        helper.setText(R.id.tvEqp,item.getEquipmentId()+"/"+item.getEquipmentType());
        helper.setText(R.id.tvCheckMan,item.getOperator());
//        helper.setText(R.id.tvEqpType,item.getEquipmentType());
        helper.setText(R.id.tvCheckTime,getDateForYYY(item.getCompleteTime().split(" ")[0]));
        helper.setText(R.id.tvCheckStatus,item.getStatus());

    }

    public static String getDateForYYY(String date){
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.valueOf(date))).toString() ;
    }


    public interface OnClickListener{
        void onCheckListener(SheetInfoEntity item);
    }

    public void setOnCheckListener(OnClickListener listener){
        this.mListener = listener;
    }
}
